package com.zhongen.oa.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.zhongen.oa.entity.ContractDetailEntity;
import com.zhongen.oa.entity.ProjectContractEntity;
import com.zhongen.oa.mapper.ContractDetailMapper;
import com.zhongen.oa.service.ContractDetailService;
import org.springframework.stereotype.Service;

/**
 * 合同明细表
 *
 * @author Code Generator
 * @date 2024-01-19 14:33:49
 */
@Service
public class ContractDetailServiceImpl extends ServiceImpl<ContractDetailMapper, ContractDetailEntity>
		implements ContractDetailService {

	@Override
	public IPage<ContractDetailEntity> getContractDetailPage(Page page, ContractDetailEntity entity) {
		MPJLambdaWrapper<ContractDetailEntity> wrapper = new MPJLambdaWrapper<ContractDetailEntity>()
			.selectAll(ContractDetailEntity.class)
			.select(ProjectContractEntity::getContractName, ProjectContractEntity::getContractNumber)
			.leftJoin(ProjectContractEntity.class, ProjectContractEntity::getId, ContractDetailEntity::getContractId)
			.eq(ContractDetailEntity::getContractId, entity.getContractId());

		return baseMapper.selectJoinPage(page, ContractDetailEntity.class, wrapper);

	}

}
